package com.ryder.petmatediarybackend.common.enums;

import lombok.Getter;

/**
 * 描述: 逻辑删除状态枚举
 *
 * @author Ryder
 * @version 1.0
 * @since 1.0
 * 更新日期: 2025/10/25
 */
@Getter
public enum IsDeleteFlagEnum {

    DELETED(1, "已删除"),
    UN_DELETED(0, "未删除");

    private final Integer code;
    private final String desc;

    IsDeleteFlagEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static IsDeleteFlagEnum getByCode(int codeVal) {
        for (IsDeleteFlagEnum isDeleteFlagEnum : IsDeleteFlagEnum.values()) {
            if (isDeleteFlagEnum.getCode() == codeVal) {
                return isDeleteFlagEnum;
            }
        }
        return null;
    }

    /**
     * 判断是否为已删除状态
     *
     * @param codeVal 状态码
     * @return true 表示已删除，false 表示未删除或无效
     */
    public static boolean isDeleted(Integer codeVal) {
        return DELETED.getCode().equals(codeVal);
    }
}

